package com.campus.chat.controller;

import com.campus.common.domain.LoginUser;
import com.campus.common.dto.ResponseDto;
import com.campus.common.dto.UserDto;
import com.campus.common.service.FriendService;
import jakarta.annotation.Resource;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

@RestController
@RequestMapping("/friend")
public class ChatController {
    @Resource
    private FriendService friendService;
    @RequestMapping("/get-friend-info")
    public ResponseDto getFriendInfo() throws IOException {
    //    WebSocket.onlineUsers.get(2).getBasicRemote().sendText("66666", true);
        UserDto userDto = (UserDto) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        ResponseDto responseDto = new ResponseDto();
        responseDto.setContent(friendService.getFriendInfos(userDto.getUserId()));
        return responseDto;
    }
}
